import 'package:flutter/material.dart';
import 'package:love_app/model/dynamic_details_model.dart';
import 'package:love_app/providers/share_provider.dart';
import 'package:love_app/service/comment_details_api.dart';
import 'package:provider/provider.dart';

// 评论页面
class Details extends StatefulWidget {

  final int itemId; // 文章id

  const Details({Key key, this.itemId}) : super(key: key);

  @override
  _DetailsState createState() => _DetailsState();
}

class _DetailsState extends State<Details> {

  int _itemId; // 文章id
  ShareProvider _shareProvider; // 全局共享数据
  var _futureBuildDetailsArticle; // 获取文章详情

  @override
  void initState() {
    super.initState();
    _itemId = widget.itemId;
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    _shareProvider = Provider.of<ShareProvider>(context, listen: false);
    _futureBuildDetailsArticle = _getDetailsArticle();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        title: Text("查看评论"),
      ),
      body: _body(),
    );
  }

  // 页面内容
  Widget _body(){
    return Container(
      child: Column(
        
      ),
    );
  }

  // 获取文章详情请求
  Future<DynamicDetailsModel> _getDetailsArticle()async{
    DynamicDetailsModel model = await CommentDetailsApi().getDynamicDetails(_shareProvider.token, _itemId);
    return model;
  }
}